package com.sensoro.factoryconfig.bean;

import android.bluetooth.BluetoothDevice;
import android.os.Parcel;
import android.os.Parcelable;

public class LeDevice implements Parcelable {
	public BluetoothDevice bluetoothDevice;
	public int rssi;
	public byte[] scanRecord;
	public int length;
	public String UMM;

	@Override
	public boolean equals(Object object) {
		if (object instanceof LeDevice) {
			return bluetoothDevice.getAddress().equals(
					((LeDevice) object).bluetoothDevice.getAddress());
		}
		return false;
	}

	public static final Creator<LeDevice> CREATOR = new Creator<LeDevice>() {

		@Override
		public LeDevice createFromParcel(Parcel source) {

			LeDevice leDevice = new LeDevice();
			leDevice.length = source.readInt();
			leDevice.bluetoothDevice = source
					.readParcelable(BluetoothDevice.class.getClassLoader());
			leDevice.rssi = source.readInt();
			leDevice.scanRecord = new byte[leDevice.length];
			source.readByteArray(leDevice.scanRecord);

			return leDevice;
		}

		@Override
		public LeDevice[] newArray(int size) {
			return new LeDevice[size];
		}
	};

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		int length = scanRecord.length;
		dest.writeInt(length);
		dest.writeParcelable(bluetoothDevice, 0);
		dest.writeInt(rssi);
		dest.writeByteArray(scanRecord);
	}
}
